package errorsim.engine;

import java.util.BitSet;
import java.util.Vector;

public class FrameList {

	private Vector<Frame> list;
	private long size;
	private long fillCount;
	private long dumpCount;
	public FrameList(long size){
		this.size = size;
		list = new Vector<Frame>();
		fillCount = 0;
		dumpCount = 0;
	}
	
	public long getFillCount() {
		return fillCount;
	}
	public long getDumpCount() {
		return dumpCount;
	}
	public synchronized void put(Frame f){
//		if(list.size() <= size/10){
			list.add(f);
			fillCount++;
//			notifyAll();
//			
//		} else
//			try {
//				wait();
//			} catch (InterruptedException e) {
//				// TODO Auto-generated catch block
//				e.printStackTrace();
//			}
		
	}
	
	public synchronized Frame take(){
//		if (list.isEmpty()){ try {
//			wait();
//		} catch (InterruptedException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}}
		
		Frame frame = list.remove(0);
		dumpCount++;
		
//		if(list.size() < size){ notifyAll();}
		return frame;
		
	}

	public synchronized boolean fillComplete() {
		return fillCount == size;
	}
	public synchronized boolean dumpComplete(){
		return dumpCount == size;
	}
	

}
